package com.guyu.plugin.password;


import com.guyu.plugin.password.crypto.impl.RsaCrypto;
import com.guyu.plugin.password.crypto.impl.SmCrypto;
import com.guyu.plugin.password.generator.DefaultPassword;

public class PasswordUtils {

    /**
     * 创建默认密码
     * 使用国密加密
     */
    public static DefaultPassword sm(String publicKeyStr, String privateKeyStr, String salt) {
        return sm(publicKeyStr, privateKeyStr, salt, 6, 16);
    }

    /**
     * 创建默认密码
     * 使用国密加密
     */
    public static DefaultPassword sm(String publicKeyStr, String privateKeyStr, String salt, int minLength, int maxLength) {
        return new DefaultPassword(new SmCrypto(publicKeyStr, privateKeyStr, salt), minLength, maxLength);
    }

    /**
     * 创建默认密码
     * 使用RSA加密
     */
    public static DefaultPassword rsa(String publicKeyStr, String privateKeyStr, String salt) {
        return rsa(publicKeyStr, privateKeyStr, salt, 6, 16);
    }

    /**
     * 创建默认密码
     * 使用RSA加密
     */
    public static DefaultPassword rsa(String publicKeyStr, String privateKeyStr, String salt, int minLength, int maxLength) {
        return new DefaultPassword(new RsaCrypto(publicKeyStr, privateKeyStr, salt), minLength, maxLength);
    }
}
